<template>
  <div class="box">
    <!-- <form action="/">
      <van-search
  v-model="value"
  placeholder="请输入搜索关键词"
  input-align="center"
  style="margin-top: 48px;"
  shape="round"
/>
</form> -->

<van-list
  style="margin-top: 40px;"
  v-model="loading"
  :finished="finished"
  finished-text="没有更多了"
  @load="onLoad"
>
<div v-for='(item, index) in list' :key="index"> 
  <!-- <div @click="toShop"> -->
    <div>
  <van-card
  :desc="item.description"
  :title="item.coursename"
  :thumb="thumb"
  @click="toMemberList(index)"
  
>
</van-card>
</div>
</div>
</van-list>
  </div>
</template>

<script>
import { Toast } from 'vant';
import axios from 'axios';

export default {
  name: 'CourseList',
  data() {
    return {
      fin:0,
      value: '',
      thumb: "https://img.yzcdn.cn/vant/cat.jpeg",
      list: [
        {
        description: "这里是javaweb的描述",
        coursename: "javaweb",
        
      },
    ],
      loading: false,
      finished: false,
    };
  },
  mounted() {
    this.loading = false;
    axios.post("/course/AllCourse").then(response => {
    console.log(response);
    this.list = response.data.data;
    console.log(this.list);
  })
  .catch(error => {
    // 处理请求过程中出现的错误
    console.error('登录请求失败:', error);
  });},
  methods: {
    // titleName(){
    //   eventBus.$emit('titleName', this.list[0].title);
    // },
    onSearch(val) {
      Toast(val);
    },
    onLoad() {
      setTimeout(() => {
        for (let i = 0; i < 100; i++) {
          this.fin += 1;
        }

        this.loading = false;

        if (this.fin >= this.list.length) {
          this.finished = true;
        }
      }, 1000);
    },
    toMemberList(title){
      // EventBus.$emit('titleName', this.list[0].title);
      this.$router.push('MemberList/' + this.list[title].coursename+'/'+this.list[title].id);  
    }
    // onCancel() {
    //   Toast('取消');
    // },
  },
};
</script>

<style scoped lang="less">
::v-deep .van-card__title {
  font-size: 500px;
  // background-color: black;
}
::v-deep .van-card__desc {
  font-size: 500px;
  background-color: white;
}
</style>